<template>
  <div>
    <info
      :arr="goodList"
      @delList="del"
      @jia="jiacount"
      @jian="jiancount"
      @show="changeType"
    ></info>
  </div>
</template>

<script>
import info from "./components/tbody";
export default {
  components: {
    info,
  },
  data() {
    return {
      goodList: [
        {
          name: "诸葛亮",
          price: 1000,
          num: 1,
          checked: false,
        },
        {
          name: "蔡文姬",
          price: 1500,
          num: 1,
          checked: false,
        },
        {
          name: "妲己",
          price: 2000,
          num: 1,
          checked: false,
        },
        {
          name: "鲁班",
          price: 2200,
          num: 1,
          checked: false,
        },
      ],
    };
  },
  methods: {
    del(index) {
      this.goodList.splice(index, 1);
    },
    jiacount(index) {
      this.goodList[index].num++;
    },
    jiancount(index) {
      this.goodList[index].num == 1 || this.goodList[index].num--;
    },
    changeType(state) {
      this.goodList.forEach((obj) => {
        obj.checked = state;
      });
    },
  },
};
</script>

<style>
</style>